﻿using System.Xml.Linq;

namespace TallyJ1Reporter.ElectionRelated
{
	public class PersonCount
	{
		//<xsd:attribute name="FName" type="xsd:string" use="required"/>
		//<xsd:attribute name="LName" type="xsd:string" use="required"/>
		//<xsd:attribute name="AKAName" type="xsd:string" use="optional"/>
		//<xsd:attribute name="BahaiId" type="xsd:string" use="optional"/>
		//<xsd:attribute name="Count" type="xsd:integer"/>
		//<xsd:attribute name="Position" type="xsd:nonNegativeInteger"/>
		//<xsd:attribute name="Section" type="xsd:string" use="optional"/>
		//<xsd:attribute name="Close" type="xsd:string" use="optional"/>
		//<xsd:attribute name="Tie" type="xsd:string" use="optional"/>
		//<xsd:attribute name="ExtraPosition" type="xsd:nonNegativeInteger" use="optional"/>
		//<xsd:attribute name="TieBreakGroup" type="xsd:nonNegativeInteger" use="optional"/>
		//<xsd:attribute name="TieCount" type="xsd:nonNegativeInteger" use="optional"/>
		//<xsd:attribute name="TieBreakResolved" type="xsd:boolean" use="optional"/>
		//<xsd:attribute name="ForceShowOther" type="xsd:boolean" use="optional"/>
		public string FName { get; private set; }
		public string LName { get; private set; }
		public string AKAName { get; private set; }
		public int Count { get; private set; }
		public int Position { get; private set; }
		public string Section { get; private set; }
		public string DisplayName
		{
			get { return string.Format("{0} {1}", FName, LName) + (string.IsNullOrEmpty(AKAName) ? "" : string.Format(" [{0}]", AKAName)); }
		}
		public PersonCount(XElement xmlElement)
		{
			FName = xmlElement.Attribute("FName").Value("");
			LName = xmlElement.Attribute("LName").Value("");
			AKAName = xmlElement.Attribute("AKAName").Value("");
			Count = xmlElement.Attribute("Count").Value(0);
			Position = xmlElement.Attribute("Position").Value(0);
			Section = xmlElement.Attribute("Section").Value("");
		}
	}
}